package com.itheima.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.CheckItemDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.CheckItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @description:
 * @author: cx
 * @date: 2020/2/23-21:36
 * @Version: 1.0.0
 */
@Service(interfaceClass = CheckitemService.class)
@Transactional
public class CheckitemServiceImpl  implements CheckitemService{

    @Autowired
    CheckItemDao checkItemDao;
    @Override
    public void add(CheckItem checkitem) {
        checkItemDao.add(checkitem);
    }

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        //告诉mybatis我现在要分页
        com.github.pagehelper.Page page = PageHelper.startPage(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());

        List<CheckItem> checkItems = checkItemDao.findPage(queryPageBean.getQueryString());
        return new PageResult(page.getTotal(),checkItems);
    }
}
